<!DOCTYPE html>
<html>
<head>
    <title>仪表板 - CVV Web</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">CVV Web</a>
            <div class="navbar-nav ms-auto">
                <span class="navbar-text me-3">欢迎, {{ current_user.username }}</span>
                <button class="btn btn-outline-light btn-sm" onclick="logout()">退出</button>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <h1>仪表板</h1>
        <div class="card">
            <div class="card-body">
                <h5 class="card-title">用户信息</h5>
                <p><strong>用户名:</strong> {{ current_user.username }}</p>
                <p><strong>用户ID:</strong> {{ current_user.user_id }}</p>
                <p><strong>用户类型:</strong>
                    {% if current_user.user_type == 2 %}
                    <span class="badge bg-warning">管理员</span>
                    {% else %}
                    <span class="badge bg-info">普通用户</span>
                    {% endif %}
                </p>
                <p><strong>邮箱:</strong> {{ current_user.email }}</p>
            </div>
        </div>
    </div>

    <script>
        function logout() {
            const token = localStorage.getItem('token');
            if (token) {
                fetch('/admin/auth/logout', {
                    method: 'POST',
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
            }
            localStorage.removeItem('token');
            window.location.href = '/login';
        }
    </script>
</body>
</html>